﻿using System;

// VERY IMPORTANT!! using System.IO
using System.IO;
    
class Directories
{
    public static void Main()
    {
        // ----------------- Creating a directory... ----------------------------------
        string directory = @"c:/probandoCondirectorys";   // Let's create a string with the path
                                                            // of the directory we want to create
        
        
        if(! Directory.Exists(directory))                  // If it doesn't exist, then we create it
            Directory.CreateDirectory(directory);


        
        // ----------------- obtaining a list of the files in a folder -----------------
        string searchingFiles = @"C:\";   // as before, we create a string with the path we want to search
        string[] savingFiles;           // and then we create the array where we will save the data we've found

        savingFiles = Directory.GetFiles(searchingFiles); // with this order, we fill the array with
                                                                // the found files
        for (int i = 0; i < savingFiles.Length; i++)
            Console.WriteLine(savingFiles[i]);              // and the we show them


        // ----------------- obtaining information about the files -----------------

        DirectoryInfo dir = new DirectoryInfo(searchingFiles); // we've created a DirectoryInfo type variable
                                                                 // that saves information about the folders

        FileInfo[] filesInformation = dir.GetFiles();       // And we've created a FileInfo type array where we've
                                                                 // saved every info about every file
        for (int i = 0; i < filesInformation.Length; i++)
            Console.WriteLine("{0}, de tamaño {1}, creado {2}",  // and then we show it
                filesInformation[i].Name,
                filesInformation[i].Length,
                filesInformation[i].CreationTime);

        // Console.ReadLine();
    }
}
